package ch7;

/**
 * @author ANG.YU
 * @date 2020-08-12 11:44
 */
public class Music4 {
    static void tune(Instrument4 i) {
        i.play();
    }

    static void tuneAll(Instrument4[] e) {
        for (Instrument4 i : e) {
            tune(i);
        }
    }

    public static void main(String[] args) {
        Instrument4[] orc = new Instrument4[5];
        int i = 0;
        orc[i++] = new Wind4();
        orc[i++] = new Percussion4();
        orc[i++] = new Percussion4();
        orc[i++] = new Brass4();
        orc[i++] = new Woodwind4();
        tuneAll(orc);
    }
}

abstract class Instrument4 {
    abstract public void play();

    public String what() {
        return "Instrument4";
    }

    abstract public void adjust();
}

class Wind4 extends Instrument4 {
    @Override
    public void play() {
        System.out.println("Wind4.play()");
    }

    @Override
    public String what() {
        return "Wind4";
    }

    @Override
    public void adjust() {
    }
}

class Percussion4 extends Instrument4 {
    @Override
    public void play() {
        System.out.println("Percussion4.play()");
    }

    @Override
    public String what() {
        return "Percussion4";
    }

    @Override
    public void adjust() {
    }
}

class Stringed4 extends Instrument4 {
    @Override
    public void play() {
        System.out.println("Stringed4.play()");
    }

    @Override
    public String what() {
        return "Stringed4";
    }

    @Override
    public void adjust() {
    }
}

class Brass4 extends Wind4 {
    @Override
    public void play() {
        System.out.println("Brass4.play()");
    }

    @Override
    public void adjust() {
        System.out.println("Brass4.adjust()");
    }
}

class Woodwind4 extends Wind4 {
    @Override
    public void play() {
        System.out.println("Woodwind4.play()");
    }

    @Override
    public String what() {
        return "Woodwind4";
    }
}
